Skip to content

switching main to local hosting branch - #147

Merged
elifouts merged 7 commits into
mainfrom
local-hosting-itx
Nov 16, 2026
Merged

elifouts merged 7 commits into
mainfrom
local-hosting-itx

Conversation

@elifouts

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI balanced review requested due to automatic review settings November 16, 2026 21:48
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T21:54:03.469223Z 0acea4f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@elifouts
elifouts merged commit 8e668cc into main Nov 16, 2026
4 checks passed
@elifouts
elifouts deleted the local-hosting-itx branch November 16, 2026 21:51

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0acea4fa2b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return
}

if blocked, retryAfter := checkLoginRateLimit(context.ClientIP(), request.Username); blocked {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Trust the proxy client IP before applying IP lockouts

In the Docker deployment, /auth/login reaches Gin through nginx on the Compose bridge, but main.go trusts only loopback proxies, so context.ClientIP() resolves to nginx's container address for every public user. After 20 failed attempts across any usernames, this shared IP key blocks all users from signing in for five minutes; trust the nginx hop or avoid aggregating this limiter across proxied clients.

Useful? React with 👍 / 👎.

Comment thread backend/api/main.go
router.GET("/messages/:username/with/:other", handlers.RequireAuth(), handlers.RequireSameUser(), handlers.GetDirectMessages)
router.POST("/messages/:username/with/:other", handlers.RequireAuth(), handlers.RequireSameUser(), handlers.CreateDirectMessage)
router.GET("/messages/:username/stream", handlers.StreamDirectMessages)
router.GET("/messages/:username/stream", handlers.RequireAuth(), handlers.RequireSameUser(), handlers.StreamDirectMessages)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Allow the WebSocket route to authenticate its token protocol

The conversation client sends the JWT in Sec-WebSocket-Protocol, but RequireAuth accepts only an Authorization: Bearer ... header. Since the middleware runs before StreamDirectMessages, its protocol-aware token extraction is never reached and every direct-message stream handshake is rejected with 401. Use middleware that reads the WebSocket protocol or leave authentication to the handler.

Useful? React with 👍 / 👎.

}

const ws = new WebSocket(wsUrl);
const ws = new WebSocket(wsUrl, [`devbits.jwt.${token}`]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Negotiate the WebSocket subprotocol the client requests

For browser/web clients, even after the route accepts this token, the constructor requires the server to select a subprotocol. The backend wsUpgrader has no configured subprotocols, so it won't acknowledge devbits.jwt.<token> and the browser fails the handshake; the WHATWG WebSocket standard requires a requested protocol to be acknowledged. Configure the upgrader to select an offered protocol or use another credential transport.

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved critical defects include a build-blocking TypeScript configuration, JWT exposure in logs, unbounded login-tracking memory growth, and deployment and restore scripts that risk downtime or incomplete data restoration.

20 open issues
What changed in this PR

This PR moves DevBits from AWS-oriented deployment to self-hosted Docker Compose and nginx, switches production defaults to devbits.ddns.net, and refreshes the admin console.

Changes:

  • Replaces AWS deployment tooling with Compose workflows, certificate management, and updated database scripts.
  • Updates mobile configuration, production URLs, WebSocket authentication, and login protection.
  • Rebuilds the admin interface and adds hosting, security, and release documentation.
File Description
TODO.md Tracks admin-console implementation and testing.
SECURITY_NEEDS.txt Adds Cloudflare Tunnel migration guidance.
README.md Describes Compose/nginx infrastructure instead of AWS.
INSTRUCTIONS.md Updates deployment and mobile publishing commands.
frontend/​tsconfig.json Adds a deprecation-suppression setting.
frontend/​services/​api.ts Switches production API defaults and fallbacks.
frontend/​RELEASE_CHECKLIST.md Adds mobile release verification steps.
frontend/​eas.json Updates production URLs and removes automatic version increments.
frontend/​app/​settings/​about.tsx Updates the public-site fallback URL.
frontend/​app/​conversation/​[username].tsx Moves WebSocket tokens into subprotocol headers.
frontend/​app/​_layout.tsx Removes startup configuration logging.
frontend/​app.json Removes the static Expo configuration.
frontend/​app.config.js Consolidates Expo settings and updates build numbers and domains.
Bash-Scripts/​run-front.sh Updates live-backend selection and environment values.
backend/​scripts/​update-live.sh Replaces native deployment with Compose updates.
backend/​scripts/​update-live.ps1 Adds Windows deployment and database-password synchronization.
backend/​scripts/​restore-deployment-db.sh Restores through the database container and restarts services.
backend/​scripts/​reset-deployment-db.sh Resets deployment data through Compose volumes.
backend/​scripts/​README.md Rewrites database and deployment operations guidance.
backend/​scripts/​issue-letsencrypt-cert.sh Adds standalone certificate issuance and renewal.
backend/​scripts/​install-aws-systemd-service.sh Removes the AWS service installer.
backend/​scripts/​deploy-aws-native.sh Removes native AWS deployment orchestration.
backend/​scripts/​build-backend-linux.sh Removes the standalone Linux build helper.
backend/​scripts/​backup-deployment-db.sh Runs database backups through Compose.
backend/​nginx/​nginx.conf Adds HTTPS routing, static hosting, logging, and rate limits.
backend/​docs/​AWS_TRANSFER_NO_NGINX.md Removes the AWS migration runbook.
backend/​docker-compose.yml Adds nginx and shared networking; restricts direct API exposure.
backend/​deploy/​systemd/​devbits-api.service Removes the native service template.
backend/​api/​main.go Updates CORS, request logging, and stream middleware.
backend/​api/​internal/​handlers/​direct_message_routes.go Adds subprotocol-token parsing and upgrade responses.
backend/​api/​internal/​handlers/​auth_routes.go Adds failed-login tracking and temporary blocking.
backend/​api/​admin/​static/​login.js Updates sign-in interactions and password visibility.
backend/​api/​admin/​static/​admin.js Replaces the console with React dashboards, search, and inspectors.
backend/​api/​admin/​static/​admin.css Adds shared responsive admin styling.
backend/​api/​admin/​index.html Redesigns the admin sign-in page.
backend/​api/​admin/​console.html Loads the React console and browser-side JSX tooling.
backend/​.env.example Updates defaults for Docker/nginx hosting.
.github/​workflows/​aws.yml Removes the AWS ECS deployment workflow.
.env.example Updates the production API example URL.
.codex Listed as changed; no content diff supplied.

Review effort: Balanced

state.blockedUntil = now.Add(loginFailureBlockFor)
}

loginFailuresByKey[key] = state
Comment thread backend/api/main.go
Comment on lines +105 to +108
path := params.Path
if path == "" && params.Request != nil && params.Request.URL != nil {
path = params.Request.URL.Path
}
Comment thread backend/nginx/nginx.conf
Comment on lines +36 to +37
access_log /dev/stdout combined if=$loggable;
access_log /dev/stdout combined if=$honeypot_loggable;
Comment on lines +72 to +81
docker compose stop nginx >/dev/null 2>&1 || true

docker run --rm \
-p 80:80 \
-v "$BACKEND_DIR/nginx/certs:/etc/letsencrypt" \
-v "$BACKEND_DIR/nginx/certs/lib:/var/lib/letsencrypt" \
certbot/certbot "${CERTBOT_FLAGS[@]}"

# Bring nginx back online.
docker compose up -d nginx >/dev/null
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -c "DROP SCHEMA IF EXISTS public CASCADE;"
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -c "CREATE SCHEMA public;"
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 < "$RESOLVED_BACKUP"
docker compose exec -T db psql -U "$DB_USER" -d postgres -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname='${DB_NAME}' AND pid <> pg_backend_pid();"
Comment thread backend/nginx/nginx.conf
Comment on lines +267 to +283
location = /api/auth/login {
limit_req zone=auth_limit burst=20 nodelay;
proxy_pass http://backend_upstream;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache off;
proxy_cache_bypass 1;
proxy_no_cache 1;
add_header Cache-Control "no-store" always;
}

location = /api/auth/register {
Comment on lines +63 to +64
if ($envRaw -match "(?m)^POSTGRES_PASSWORD=(.+)$") {
$dbPass = $Matches[1].Trim()
Comment on lines +84 to +85
docker compose up -d --build backend nginx
Write-Host "Backend and nginx services have been updated." -ForegroundColor Green
}

const ws = new WebSocket(wsUrl);
const ws = new WebSocket(wsUrl, [`devbits.jwt.${token}`]);
Comment thread SECURITY_NEEDS.txt
Comment on lines +40 to +41
5.5) Service Type: HTTP.
5.6) URL: localhost:80.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants